$(document).ready(function(){
	
	var str = "http://fish.yfi.ac.cn:80/Fish/picture/";
    //var str = "http://localhost:8080/Fish/picture/";
	var images;
	var selectID;
	function show(){
		if(images.length === 0) {alert("未上传照片");return;}
		$("#showAll").css({"display":"block"});
        $("#imgDiv").css({"display":"inline-block"});
       
		console.log("  ddd  "+images.length);
		console.log(str+selectID+"/"+images[0]);
		$("#img1").attr("src",str+selectID+"/"+images[0]);
	}
	
	$("button").each(function(i,n){
		$(this).click(function(){
			if($(this).attr("name").length !== 0)
			    images = $(this).attr("name").split("|");
			else
				images =[];
			selectID = $(this).attr("id");
			show();
	      //  $("#showAll").css({"display":"block"});
		});
	});
	
	   var currnt = 0;
	    $("#last").click(function () {
	            var src;
	            if(currnt === 0) currnt = images.length-1;
	            else currnt--;
	            $("#img1").attr("src",str+selectID+"/"+images[currnt]+"?t=" + Math.random());
	     });

	     $("#next").click(function(){
	         if(currnt === images.length-1) currnt=0;
	         else currnt++;
	         $("#img1").attr("src",str+selectID+"/"+images[currnt]+"?t=" + Math.random());

	     });
	
    $(".close").click(function(){
        $("#showAll").css({"display":"none"});
        $("#imgDiv").css({"display":"none"});

    });
	
});
